<template>
  <rt-list
    ref="moresearchList"
    :table-name="tableName"
    :columns="columns"
    :title="title"
    :controller-name="controllerName"
    :search-param="searchList"
    :operations="operations"
    :input-search-param="quickSearch"
    :custom-operations="customOperations"
    :custom-button-operation="customButtonOperations"
    :hide-title="false"
    :is-multiple="false"
    :reset="reset"
    :line-break="true"
    :export-params="exportParams"
    search-placeholder="输入昵称快速搜索"
  >
    <rt-form slot="search">
      <rt-row :gutter="15">
        <rt-col :span="6">
          <rt-form-item label="昵称">
            <rt-input v-model="tableParam.nickname" />
          </rt-form-item>
        </rt-col>
        <rt-col :span="6">
          <rt-form-item label="客户名称">
            <rt-input v-model="tableParam.bbs_account_name" />
          </rt-form-item>
        </rt-col>
        <rt-col :span="6">
          <rt-form-item label="姓名">
            <rt-input v-model="tableParam.name" />
          </rt-form-item>
        </rt-col>
        <rt-col :span="6">
          <rt-form-item label="电话">
            <rt-input v-model="tableParam.mobilephone" />
          </rt-form-item>
        </rt-col>
      </rt-row>
    </rt-form>
  </rt-list>
</template>

<script>
import RtList from '../../components/custome/rtList.vue';
export default {
  name: 'ContactList',
  components: {
    RtList
  },
  data() {
    return {
      controllerName: 'bbs/contact',
      tableName: 'bbs_contact',
      title: '联系人列表',
      queryValue: '',
      operations: ['search', 'advanced-search', 'exportcontact'],
      columns: [
        {
          prop: 'nickname',
          label: '昵称',
          sortable: true
        },
        {
          prop: 'bbs_account_name',
          label: '客户名称',
          sortable: true,
          autoCol: true
        },
        {
          prop: 'name',
          label: '姓名',
          sortable: true,
          autoCol: true
        },
        {
          prop: 'mobilephone',
          sortable: true,
          label: '电话'
        }
      ],
      tableParam: {
        nickname: '',
        bbs_account_name: '',
        name: '',
        mobilephone: ''
      },
      quickSearch: ['nickname'],
      customOperations: [
        {
          operate: 'exportcontact',
          operateName: '导出',
          iconName: 'rt-portal-export',
          type: 'primary'
        }
      ],
      exportParams: {
        headerMap: {
          nickname: '昵称',
          bbs_account_name: '客户名称',
          name: '姓名',
          mobilephone: '电话'
        },
        fileName: '联系人列表'
      },
      customButtonOperations: {
        exportcontact: () => {
          this.$refs.moresearchList.exportViewData();
        }
      }
    };
  },
  computed: {
    searchList() {
      const searchList = [];
      if (!rt.isNil(this.tableParam.nickname)) {
        searchList.push({
          key: 'nickname',
          value: this.tableParam.nickname,
          operator: 'like'
        });
      }
      if (!rt.isNil(this.tableParam.bbs_account_name)) {
        searchList.push({
          key: 'bbs_account_name',
          value: this.tableParam.bbs_account_name,
          operator: 'like'
        });
      }
      if (!rt.isNil(this.tableParam.name)) {
        searchList.push({
          key: 'name',
          value: this.tableParam.name,
          operator: 'like'
        });
      }
      if (!rt.isNil(this.tableParam.mobilephone)) {
        searchList.push({
          key: 'mobilephone',
          value: this.tableParam.mobilephone,
          operator: 'like'
        });
      }
      return searchList;
    }
  },
  created() {},
  methods: {
    reset() {
      this.tableParam.nickname = '';
      this.tableParam.bbs_account_name = '';
      this.tableParam.name = '';
      this.tableParam.mobilephone = '';
    }
  }
};
</script>

<style scoped></style>
